package com.ruoyi.web.core.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;

@Configuration
public class RestTemplateConfig {

    /**
     * 使用 RestTemplateBuilder 配置 RestTemplate Bean
     * @param builder RestTemplateBuilder 实例
     * @return RestTemplate 实例
     */
    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder
                .setConnectTimeout(Duration.ofSeconds(50000))
                .setReadTimeout(Duration.ofSeconds(50000))
                .build();
    }
}
